package com.ylsk.check.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ylsk.check.domain.dto.RectificationReviewDTO;
import com.ylsk.check.domain.so.RectificationReviewSO;
import com.ylsk.check.domain.vo.RectificationReviewVO;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ylsk.common.annotation.Log;
import com.ylsk.common.core.controller.BaseController;
import com.ylsk.common.core.domain.AjaxResult;
import com.ylsk.common.enums.BusinessType;
import com.ylsk.check.domain.RectificationReview;
import com.ylsk.check.service.IRectificationReviewService;
import com.ylsk.common.utils.poi.ExcelUtil;
import com.ylsk.common.core.page.TableDataInfo;

/**
 * 整改复查Controller
 *
 * @author ysy
 * @date 2023-12-26
 */
@RestController
@RequestMapping("/check/rectificationReview")
public class RectificationReviewController extends BaseController
{
    @Autowired
    private IRectificationReviewService rectificationReviewService;

    /**
     * 查询整改复查列表
     */
    @PreAuthorize("@ss.hasPermi('check:rectificationReview:list')")
    @GetMapping("/list")
    public TableDataInfo list(RectificationReviewSO rectificationReviewSO)
    {
        startPage();
        List<RectificationReviewVO> list = rectificationReviewService.selectRectificationReviewList(rectificationReviewSO);
        return getDataTable(list);
    }

    /**
     * 导出整改复查列表
     */
    @PreAuthorize("@ss.hasPermi('check:rectificationReview:export')")
    @Log(title = "整改复查", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, RectificationReviewSO rectificationReviewSO)
    {
        List<RectificationReviewVO> list = rectificationReviewService.selectRectificationReviewList(rectificationReviewSO);
        ExcelUtil<RectificationReviewVO> util = new ExcelUtil<RectificationReviewVO>(RectificationReviewVO.class);
        util.exportExcel(response, list, "整改复查数据");
    }

    /**
     * 获取整改复查详细信息
     */
    @PreAuthorize("@ss.hasPermi('check:rectificationReview:query')")
    @GetMapping(value = "/{rectificationReviewId}")
    public AjaxResult getInfo(@PathVariable("rectificationReviewId") Long rectificationReviewId)
    {
        return success(rectificationReviewService.selectRectificationReviewByRectificationReviewId(rectificationReviewId));
    }

    /**
     * 新增整改复查
     */
    @PreAuthorize("@ss.hasPermi('check:rectificationReview:add')")
    @Log(title = "整改复查", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody RectificationReviewDTO rectificationReviewDTO)
    {
        return toAjax(rectificationReviewService.insertRectificationReview(rectificationReviewDTO));
    }

    /**
     * 修改整改复查
     */
    @PreAuthorize("@ss.hasPermi('check:rectificationReview:edit')")
    @Log(title = "整改复查", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody RectificationReviewDTO rectificationReviewDTO)
    {
        return toAjax(rectificationReviewService.updateRectificationReview(rectificationReviewDTO));
    }

    /**
     * 删除整改复查
     */
    @PreAuthorize("@ss.hasPermi('check:rectificationReview:remove')")
    @Log(title = "整改复查", businessType = BusinessType.DELETE)
	@DeleteMapping("/{rectificationReviewIds}")
    public AjaxResult remove(@PathVariable Long[] rectificationReviewIds)
    {
        return toAjax(rectificationReviewService.deleteRectificationReviewByRectificationReviewIds(rectificationReviewIds));
    }
}
